import 'package:flutter_nb_net/flutter_net.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:tracker/common/constants/app_constants.dart';
import 'package:tracker/pages/home/vip_service/model/vip_service_list_resp.dart';

import '../../../../common/log/x_logger.dart';
import '../../../../provider/global_provider.dart';
import '../../home/model/home_device_info_resp.dart';

mixin SecurityServiceMixin<T extends ConsumerStatefulWidget>
    on ConsumerState<T> {
  List<VipServiceData> securityVipServiceData = []; // 安防
  int securityIndex = 0;
  int securityPayIndex = 0;

  /// 获取设备套餐列表
  Future<VipServiceListResp> getPackageList(int type) async {
    DeviceInfoVO deviceInfo = ref.read(deviceInfoProvider);

    final res = await get<VipServiceListResp, VipServiceListResp>(
        '$newBaseULr/package/list',
        queryParameters: {"type": type, "order": "desc",'imei': deviceInfo.imei,},
        decodeType: VipServiceListResp());
    return res.when(success: (resp) {
      return resp;
    }, failure: (String msg, int code) {
      XLogger.error('获取设备套餐列表失败：msg: $msg, code: $code');
      return VipServiceListResp();
    });
  }



}
